<template>
  <div class="sign_list">
    <div class="search-input">
      <div class="si">
        <el-icon>
          <Search />
        </el-icon>
        <input placeholder="请输入" v-model="realName"/>
        <span class="btn" @click="query">搜索</span>
      </div>
    </div>

    <div class="data_list data-list-player">
      <div class="data">
        <div class="item" v-for="(item ,index) in pageInfo.list" :key="index">
          <div class="title">{{item.real_name}}</div>
          <div class="attr">参赛单位：{{item.company}}</div>
          <div class="attr">注册时间：{{item.create_date}}</div>
          <div class="btns">
            <el-button type="text" @click="handleInfo(item.id)">个人信息</el-button>
            <el-button type="text" @click="handleMatch(item.id,item.real_name)">参赛记录</el-button>
            <el-button type="text" @click="toCertificateList(item.real_name, item.id_card)">获奖证书</el-button>
          </div>
        </div>
      </div>

    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, getCurrentInstance } from "vue";
import { useRouter } from "vue-router";
import baseService from "@/service/baseService";
import {setCache} from "@/utils/cache";
let router = useRouter();
let currentInstance = getCurrentInstance();
const realName =ref();
const handleInfo = (id:number) => {
  router.push({path:"/match/player_info",query:{id:id }});
};
const handleMatch = (id:number,userName:string) => {
  router.push( {path:"/match/player_match_list",query:{userId:id,userName }});
};
const handleJie = (id:number) => {
  currentInstance?.proxy?.$mesage.openModal({
    text: "是否确认解除绑定？",
    success: () => {
      alert("我点击了确定");
    },
    cancel: () => {
      alert("我点击了取消");
    },
  });
  currentInstance?.proxy?.$mesage.openToast({
    text: "是否确认解除绑定？",
  });
};
const pageInfo = ref({list:[]});

const query = () => {
  let param :any= {};
  if(realName.value){
    param.realName= realName.value;
  }
  baseService
      .get("/front/fast/user/userList/page?pageSize=10&type=4&order=&orderField=&page=1&pageNumber=1&limit=10&status=&name=&_t=1710085232037", {
        pageNumber: 1,
        pageSize: 99,
        loginType: "wap",
        ...param
      })
      .then((res) => {
        console.log(res);
        pageInfo.value.list = res.data.list;
      });
};

const toCertificateList = (realName:any, idCard:any) => {
  const certificate = {
    realName: realName,
    idCard: idCard
  };
  setCache("certificate", certificate, true);
  router.push('/wap/certificate_student')
};

query();

</script>

<style lang="scss" scoped>
@import "./style.scss";
</style>
